import { Request, toast } from '../../../utils/util.js'
let request = new Request()
let app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    userType : 0
  },

  navTo (e) {


    request.post('sms/merchantApply', res => {}, {mobile : '13542046429'});
return

    let dataset = e.currentTarget.dataset
    let type = dataset.type
    if(type != 1) {
      if(this.data.userType != 2) {
        wx.showModal({
          title: '提示',
          content: '该类型只有商家才能发布',
          confirmText : '成为商家',
          success : (res) => {
            if (res.confirm) {
              wx.redirectTo({
                url: '/pages/applyMerchant/index',
              })
            }
          }
        })

        return
      }
    }
    wx.navigateTo({
      url: dataset.url,
    })
  },

  onLoad: function (options) {
    let userInfo = app.globalData.userInfo
    if (userInfo.user_type != 2) {
      request.get('user/userfield/user_type', res => {
        if(res.success) {
          let userType = res.data.user_type
          if (userType == 2) {
            this.setData({ userType: userType})
            userInfo.user_type = userType
            wx.setStorage({
              key: 'userinfo',
              data: userInfo
            })
          }
        }
      }).showLoading()
    }else{
      this.setData({ userType: userInfo.user_type})
    }
  }
})